package cn.yang.controller;

import cn.yang.domain.TDevice;
import cn.yang.service.TDeviceService;
import cn.yang.service.TDeviceTypeService;
import cn.yang.service.TUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//设备的控制层
@RestController
@RequestMapping("dev")
public class DeviceController {
    @Autowired
    TDeviceService tDeviceService;
    @Autowired
    TDeviceTypeService tDeviceTypeService;
    @Autowired
    TUserService tUserService;
    //设备列表
    @GetMapping("dlist")
    public String dlist(){
        return tDeviceService.list().toString();
    }
    //根据id获取设备
    @GetMapping("getdOne")
    public String getdOne(@RequestParam Integer did){
        return tDeviceService.getById(did).toString();
    }
    //添加设备或者修改设备
    @PostMapping("saveOrUpdate")
    public Boolean saveOrUpdate(@RequestBody TDevice device){
        return tDeviceService.saveOrUpdate(device);
    }
    //类型列表
    @GetMapping("tlist")
    public String tlist(){
        return tDeviceTypeService.list().toString();
    }
    //登录
    @PostMapping("login")
    public String login(@RequestParam String username,@RequestParam String password){
        return tUserService.list().toString();
    }
}
